package com.yidu.BusinessData.controller;


import com.yidu.BusinessData.entity.Fund;
import com.yidu.BusinessData.service.FundService;
import com.yidu.TAManagement.entity.TABusiness;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class FundController {
    @Resource
    private FundService fundService;
    /**
     * 增加基金
     * @param fund 基金对象
     * @return 返回1 则正确 反之 则失败
     */
    @PostMapping("/insertFund")
    public int insertFund(Fund fund){
        System.out.println("000");
        return fundService.insertFund(fund);
    }
    /**
     * 按条件查询加分页
     * @param page   页码
     * @param limit 每页显示的行数
     * @param  fund 查询的条件
     * @return 返回用户的集合
     */
    @RequestMapping("/selectFund")
    public Map selectFund(int page, int limit, Fund fund){
        Map fundMap=new HashMap();
        List<Fund> fundList = fundService.selectFund(page, limit, fund);
        System.out.println("fund=" + fundList);
        //获取总记录数
        int count=fundService.Fundtotal(fund);
        fundMap.put("data",fundList);
        fundMap.put("code",0);
        fundMap.put("msg","");
        fundMap.put("count",count);
        return fundMap;

    }

    @RequestMapping("/selectFundLogin")
    public List<Fund> selectFundLogin(Fund fund){
        List<Fund> fundList = fundService.selectFund(1, 10, fund);
        System.out.println("fund=" + fundList);
        return fundList;

    }

    /**
     * 修改基金
     * @param fund 基金对象
     * @return 返回1 则正确 反之 则失败
     */
    @PutMapping("/updateFund")
    public int updateFund(Fund fund){
        return fundService.updateFund(fund);
    }
    @DeleteMapping("/deleteFund")
    public int deleteFund(String fundId)
    {
        System.out.println(fundId);
        return fundService.deleteFund(fundId);
    }

}
